<?php
/**
 * ModelLoader.php
 * 
 * @category    Madoqua
 * @package     Controller
 * @subpackage  Helper
 */

/** base class */
require_once 'Zend/Controller/Action/Helper/Abstract.php';

/** madoqua loader */
require_once 'Madoqua/Loader.php';

/**
 * Madoqua_Controller_Action_Helper_ModelLoader
 * 
 * @category    Madoqua
 * @package     Controller
 * @subpackage  Helper
 */
class Madoqua_Controller_Action_Helper_ModelLoader extends Zend_Controller_Action_Helper_Abstract
{
    /**
     * load a (set of) models
     *
     * @param string|array $models
     * @return Madoqua_Controller_Action_Helper_ModelLoader
     */
    public function load($models)
    {
        Madoqua_Loader::loadModel($models);
        return $this;
    }
    
    /**
     * get a single model
     *
     * @param string $model
     * @return Zend_Db_Table_Abstract
     */
    public function get($model)
    {
        $this->load($model);
        return new $model;
    }    
    
    /**
     * alas method for load()
     *
     * @param string|array $model
     * @return Madoqua_Controller_Action_Helper_ModelLoader
     */
    public function direct($models)
    {
        $this->load($models);
        return $this;
    }
    
    
}
